package com.lyz.dataStructure.algorithm.商汤科技2020;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 20:38
 * @Description:
 **/

import org.omg.Messaging.SYNC_WITH_TRANSPORT;

import java.util.*;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/8/19 20:38
 *@Description:
 **/
public class Main4 {
    Map<Integer,Integer> count;
    Map<Integer,List<Integer>> graph;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N =sc.nextInt();
        int[] nums = new int[N];
        for(int i=0;i<nums.length;i++){
            nums[i] = sc.nextInt();
        }
        Main4 m = new Main4();
        System.out.println(m.nnumSquarefulPerms(nums));
    }
    public  int nnumSquarefulPerms(int[] A){
        int N = A.length;
        count = new HashMap<>();
        graph = new HashMap<>();
        for(int x:A)
            count.put(x,count.getOrDefault(x,0)+1);

        for(int x:count.keySet())
            graph.put(x,new ArrayList());
        for(int x:count.keySet()){
            for(int y:count.keySet()){
                int r = (int)(Math.sqrt(x+y)+0.5);
                if(r*r==x+y)
                    graph.get(x).add(y);
            }

        }
        int ans = 0;
        for(int x:count.keySet())
            ans += dfs(x,N-1);
        return ans;
    }

    public int dfs(int x,int todo){
        count.put(x,count.get(x)-1);
        int ans = 1;
        if(todo!=0){
            ans=0;
            for(int y:graph.get(x))
                if(count.get(y)!=0){
                    ans+=dfs(y,todo-1);
                }
        }
        count.put(x,count.get(x)+1);
        return ans;
    }
}
